<?php
if($this->ma == 1){
    echo '<script language="javascript" type="text/javascript">alert("运单快递价格记录修改成功！");</script>';
}else if($this->ma == 2 ){
    echo '<script language="javascript" type="text/javascript">alert("该价格记录不存在！");</script>';
}
?>

<div class="admin_nrtop">
    <div class="wupintopleft">
        <div class="wupincz">
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a href="/admini/express/price" class="nui-btn-text"><span>&lt;&lt;</span>返回<input type="hidden" id="priceId" name="priceId" value="<?php echo $this->priceItem->Id;?>" /></a>
                </div>
            </div>
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a href="/admini/express/addprice/epId/<?php echo $this->priceItem->expressId; ?>/cityId/<?php echo $this->priceItem->cityId; ?>" name="editEp" class="nui-btn-text editEp">修改信息</a>
                </div>
                <?php if($this->priceItem->IsDisable == 1) { ?>
                    <div class="nui-btn ">
                        <a href="javascript:void(0);"  class="nui-btn-text EnableOrDisable" i="启用">启用</a>
                    </div>
                <?php } else { ?>
                    <div class="nui-btn ">
                        <a href="javascript:void(0);"  class="nui-btn-text EnableOrDisable" i="禁用">禁用</a>
                    </div>
                <?php } ?>
                <div class="nui-btn ">
                    <a href="javascript:void(0);"  class="nui-btn-text delExpress">删除</a>
                </div>
            </div>
        </div>
    </div>
    <div class="addbox">
        <div class="addtop">
            <h1></h1>
        </div>
        <div class="addtable">
            <table>
                <tbody>
                    <tr>
                        <td class="addl">快递方式:</td>
                        <td><?php echo $this->priceItem->Express->Name; ?></td>
                    </tr>
                    <tr>
                        <td class="addl">国家:</td>
                        <td><?php echo $this->priceItem->City->Name; ?></td>
                    </tr>
                    <tr>
                        <td class="addl">最大限重:</td>
                        <td>
                            <?php echo $this->priceItem->Maxkg; ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="addl">最大限长:</td>
                        <td>
                            <?php echo $this->priceItem->Maxcm; ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="addl">首重:</td>
                        <td>
                            <?php echo $this->priceItem->FirstWeight; ?>
                        </td>
                    </tr>
                    <?php if($this->priceItem->Pricingxz){ ?>
                    <tr>
                        <td class="addl">续重价格:</td>
                        <td>
                            <table style="width:200px" border="1">
                                <tr>
                                    <td>重量段</td>
                                    <td>重量段</td>
                                    <td>续重价</td>
                                </tr>
                            <?php foreach ($this->priceItem->Pricingxz as $key => $p) {?>
                                  <tr>
                                    <td><?= $p->start ;?></td>
                                    <td><?= $p->end ;?></td>
                                    <td><?= $p->price ;?></td>
                                  </tr>
                           <?php } ?>
                           </table>
                        </td>
                    </tr>
                    <?php } ?>
                    <tr>
                        <td class="addl">首重价:</td>
                        <td>
                            <?php echo $this->priceItem->FirstPrice; ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="addl">续重:</td>
                        <td>
                            <?php echo $this->priceItem->SubsequentWeight; ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="addl">按公斤计费:</td>
                        <td>
                            <?php echo $this->priceItem->IsWeight == '1' ? '开启' : '关闭' ; ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="addl">超过按公斤算:</td>
                        <td>
                            <?php echo $this->priceItem->Beyond; ?>
                        </td>
                    </tr>
                    <?php if($this->priceItem->IsWeight ==1 && $this->priceItem->Pricinggj){ ?>
                    <tr>
                        <td class="addl">公斤价格:</td>
                        <td>
                            <table style="width:200px" border="1">
                                <tr>
                                    <td>重量段</td>
                                    <td>重量段</td>
                                    <td>续重价</td>
                                </tr>
                            <?php foreach ($this->priceItem->Pricinggj as $key => $p) {?>
                                  <tr>
                                    <td><?= $p->start ;?></td>
                                    <td><?= $p->end ;?></td>
                                    <td><?= $p->price ;?></td>
                                  </tr>
                           <?php } ?>
                           </table>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div style="clear:both"></div>
</div>

<div class="wupincz wpdibu" id="wupincz">
      <div class="nui-toolbar-item">
        <div class="nui-btn ">
            <a href="/admini/express/index" class="nui-btn-text"><span>&lt;&lt;</span>返回<input type="hidden" id="epId" name="epId" value="<?php echo $this->priceItem->Id;?>" /></a>
        </div>
    </div>                    
    <div class="nui-toolbar-item">
        <div class="nui-btn ">
            <a href="/admini/express/addprice/epId/<?php echo $this->priceItem->expressId; ?>/cityId/<?php echo $this->priceItem->cityId; ?>" name="editEp" class="nui-btn-text editEp">修改信息</a>
        </div>
        <?php if($this->priceItem->IsDisable == 1) { ?>
            <div class="nui-btn ">
                <a href="javascript:void(0);"  class="nui-btn-text EnableOrDisable" i="启用">启用</a>
            </div>
        <?php } else { ?>
            <div class="nui-btn ">
                <a href="javascript:void(0);"  class="nui-btn-text EnableOrDisable" i="禁用">禁用</a>
            </div>
        <?php } ?>
        <div class="nui-btn ">
            <a href="javascript:void(0);"  class="nui-btn-text delExpress">删除</a>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
            $.fn.numeral = function () {
                    $(this).css("ime-mode", "disabled");
                    this.bind("keypress", function (e) {
                        var code = (e.keyCode ? e.keyCode : e.which);  //兼容火狐 IE   
                        if (!$.browser.msie && (e.keyCode == 0x8))  //火狐下 不能使用退格键  
                        {
                            return;
                        }
                        return code >= 48 && code <= 57 || code == 46;
                    });
                    this.bind("blur", function () {
                        if (this.value.lastIndexOf(".") == (this.value.length - 1)) {
                            this.value = this.value.substr(0, this.value.length - 1);
                        } else if (isNaN(this.value)) {
                            this.value = " ";
                        } 
                    });
                    this.bind("paste", function () {
                        var s = clipboardData.getData('text');
                        if (!/\D/.test(s));
                        value = s.replace(/^0*/, '');
                        return false;
                    });
                    this.bind("dragenter", function () {
                        return false;
                    });
                    this.bind("keyup", function () {
                        this.value = this.value.replace(/[^\d.]/g, "");
                        //必须保证第一个为数字而不是.
                        this.value = this.value.replace(/^\./g, "");
                        //保证只有出现一个.而没有多个.
                        this.value = this.value.replace(/\.{2,}/g, ".");
                        //保证.只出现一次，而不能出现两次以上
                        this.value = this.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
                    });
                };
            $("#formstore #firstWeight").numeral();
            $("#formstore #subsequentWeight").numeral();
            $("#formstore #firstPrice").numeral();
            $("#formstore #subsequentPrice").numeral();
            $("#formstore #mintime").numeral();
            $("#formstore #maxtime").numeral();
            $("#formstore #firstReport").numeral();
            $("#formstore #subsequentReport").numeral();
            $("#formstore #price5").numeral();
            $("#formstore #price10").numeral();
            $("#formstore #price20").numeral();
            $("#formstore #price40").numeral();
            $("#formstore #price70").numeral();
        });
    $(".EnableOrDisable").click(function(){
        var id = $("#priceId").val();
        var i = $(this).attr("i");
        if(confirm("您确定"+i+"该快递价格？","提示信息")){            
            $.ajax({    
                type: 'POST',
                url: '/admini/express/eodprice/id/'+id,
                success: function(data) {
                    if(data == 1){
                        alert(i+"成功！");
                        location.reload();
                    }else{
                        alert("发生未知错误，请重新操作");
                    }
                }
            });
        }
    });
    $(".delExpress").click(function(){
        var id = $("#priceId").val();
        if(confirm("您确定删除该快递价格？","提示信息")){            
            $.ajax({    
                type: 'POST',
                url: '/admini/express/delexpress/id/'+id,
                success: function(data) {
                    if(data == 1){
                        alert("删除成功！");
                        location.href="/admini/express/price";
                    }else{
                        alert("发生未知错误，请重新操作");
                    }
                }
            });
        }
    });
    $(".editEp").click(function(){
        $(".wupininfo").hide();
        $("#editdetail").show();
    });
    $("#rehref").click(function(){
        $(".wupininfo").show();
        $("#editdetail").hide();
    });
    $('#submit').click(function(){
         if($("#firstWeight").val() == '' ){
            alert("首重不能为空！");
            return false;
        }else if($("#subsequentWeight").val() == ''){
            alert("续重不能为空！");
            return false;
        }else if($("#firstPrice").val() == ''){
            alert("首重价不能为空！");
            return false;
        }else if($("#subsequentPrice").val() == ''){
            alert("续重价不能为空！");
            return false;
        }else if($("#mintime").val() == ''){
            alert("运输最小时间不能为空！");
            return false;
        }else if($("#maxtime").val() == ''){
            alert("运输最大时间不能为空！");
            return false;
        }else if($("#firstReport").val() == ''){
            alert("官方首重报价不能为空！");
            return false;
        }else if($("#subsequentReport").val() == ''){
            alert("官方续重报价不能为空！");
            return false;
        }else if($("#price5").val() == ''){
            alert("5KG以上续重价不能为空！");
            return false;
        }else if($("#price10").val() == ''){
            alert("10KG以上续重价不能为空！");
            return false;
        }else if($("#price20").val() == ''){
            alert("20KG以上续重价不能为空！");
            return false;
        }else if($("#price140").val() == ''){
            alert("40KG以上续重价不能为空！");
            return false;
        }else if($("#price70").val() == ''){
            alert("70KG以上续重价不能为空！");
            return false;
        }else{
            return true;
        }
    });
    
    $('#state_div').hover(function(){
    },function(){
        $('.guojiaceng').hide();
    }).click(function(){
        $('.guojiaceng').show();
    });
    $('.countrylist a').bind('click',function(){
        var city =$(this).text();
        var state = $(this).attr("cid");
        $("#cityId").val(state);
        $("#cityName").val(city);
        $('.guojiaceng').hide();
        return false;
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
</script>



